<template>
    <div class="ordering">
        <div>
        <el-page-header>
            <template #breadcrumb>
                <el-breadcrumb separator="/">
                    <el-breadcrumb-item :to="{ path: 'home' }">
                        学生主页
                    </el-breadcrumb-item>
                    <el-breadcrumb-item>企业评价</el-breadcrumb-item>
                </el-breadcrumb>
            </template>
        </el-page-header>
    </div><br/>
        <div class="heading">企业评价表</div><br/>
        <div>
            <el-table :data="tableData" height="360" style="width: 100%">
                <el-table-column prop="companyName" label="企业名" min-width="100" />
                <el-table-column prop="companyPhone" label="联系方式" min-width="100" />
                <el-table-column prop="companyInfo" label="企业信息" min-width="100" />
                <el-table-column prop="companyTrade" label="行业" min-width="100" />
                <el-table-column fixed="right" label="操作" min-width="100">
                    <template #default="scope">
                        <el-button text @click="ooo(scope.row)" style="background-color: #545c64;color: aliceblue;">
                            企业评价
                        </el-button>
                        <el-dialog v-model="dialogFormVisible" title="输入评价内容">
                            <el-form :model="form">
                                <el-form-item label="评价内容：" :label-width="formLabelWidth">
                                    <el-input v-model="textarea.evaluationContant" autocomplete="off" type="textarea"
                                        placeholder="请输入对本企业的评价" style="height: 100px;" />
                                </el-form-item>
                            </el-form>
                            <template #footer>
                                <span class="dialog-footer">
                                    <el-button type="primary" @click="updata" style="background-color: #545c64;">提交评价</el-button>
                                    <el-button @click="dialogFormVisible = false">
                                        完成
                                    </el-button>
                                </span>
                            </template>
                        </el-dialog>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <br/>
        <el-button type="info" @click="bbb">我的评价</el-button><br/>
        <div
            style="height: 150px; width: auto; border-style:dashed;border-width: 0.1px;border-color: gray;border-radius:10px;">
            <p style="text-indent: 2em; color: #545c64; font-size:2px;">
                希望同学们认真进行评价,禁止发布不良言论，一旦发出就不可更改。一定对自己的言论负责！！！！
            </p><br />
        </div>
    </div>
</template>

<script setup>
import { ref, onBeforeMount, reactive } from 'vue'
import requests from '@/api/ajax.js'
import { ArrowRight } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'

const dialogFormVisible = ref(false)
const formLabelWidth = '140px'



const textarea = ref({
    evaluationContant:'',
    companyId: '',
})



function ooo(row){
     dialogFormVisible.value = true;
    textarea.value.evaluationContant = '';
    console.log(row);
    textarea.value.companyId = row.companyId;
}

function updata(){
    const acd = requests({ url: "/students/addMyEvaluation", method: "post", data: textarea.value }).then(res => {
    //存储用户信息到浏览器toke

  })
    .catch(err => {
      console.error(err.data);
      // 登录请求失败后的操作
    })

  alert('评价成功')
}

const tableData = ref([{
    evaluationId: '',
    companyId: '',
    evaluationContant: '',
    memberId: '',
    evaluationDate:'',
    studentId: '',
    memberState: '',
    teamId: '',
    companyName: '',
    companyInfo: '',
    companyPhone: '',
    companyTrade: '',
    companyPassword: '',
}])

onBeforeMount(() => {

    //请求能够发出组队邀请的学生信息
    const aacom = requests({ url: "/students/allcompanyDetailVo", method: "get", }).then(res => {
        //存储用户信息到浏览器toke
        const abc = res.rdata
        tableData.value = abc
        console.log(res)
    })
        .catch(err => {
            console.error(err.data);
            // 登录请求失败后的操作
        });
})

const aaa = ref([
    {
        companyId: '1',
        companyName: '叽叽叽叽',
        companyPhone: '145564648548',
        companyInfo: '非常好',
        companyTrade: '大数据',
    },
    {
        companyId: '2',
        companyName: 'ikun',
        companyPhone: '1649879764646',
        companyInfo: '小黑子',
        companyTrade: '互联网',
    },
])

const router_useRouter = useRouter()
function bbb() {
  router_useRouter.push({ path: 'myEvaluation' })
}
</script>

<style scoped>
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>